# json序列化
import json

if __name__ == '__main__':
    # 声明原始参数
    param = {
        'name': 'zsa',
        'age': 32,
        'score': 99.5
    }

    # 使用json.dump函数进行序列化,生成json格式的字符串
    json_str = json.dumps(param)
    print('after json_serialization serialization')
    print('type of json_str is {}, value is {}'.format(type(json_str), json_str))

    # 使用json.loads函数进行反序列化,将json格式的字符串解析为dict字典
    origin_param = json.loads(json_str)
    print('after json_serialization deserialization')
    print('type of origin_param is {}, value is {}'.format(type(origin_param), origin_param))
